<!DOCTYPE HTML>
<html>
<head>
<include file="public/header" />
<title>管理员添加</title>
</head>
<body>
<article class="page-container">
	<form class="form form-horizontal" id="form-admin-add">
	<if condition="!isset($user.id)">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>管理员密码：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="password" class="input-text" value="" placeholder="请填写管理员用密码" id="userpwd" name="userpwd">
			</div>
		</div>
	</if>
	<if condition="!isset($user.id)">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>确认管理员密码：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="password" class="input-text" value="" placeholder="请再次填写管理员用密码" id="reuserpwd" name="reuserpwd">
			</div>
		</div>
	</if>
	
	<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
			<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
		</div>
	</div>
	<input type="hidden" name="id" value="{$id}" />
	</form>
</article>

<include file="public/footer" />

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/messages_zh.js"></script> 
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$("#form-admin-add").validate({
		rules:{
			userpwd:{
				required:true,
			},
			reuserpwd:{
				required:true,
				equalTo: "#userpwd"
			}
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$(form).ajaxSubmit({
				type: 'post',
				url: "{:url('User/editpwd')}" ,
				success: function(data){
					if(data.error=="success"){
						layer.msg('操作成功!',{icon:6,time:1000});
						setTimeout(function(){
							parent.location.replace(parent.location.href)
						},1500);
					}else{
						layer.msg(data.error,{icon:5,time:2000});
					}
				},
                error: function(err){
                	document.write(JSON.stringify(err));
					layer.msg('操作失败！',{icon:5,time:2000});
				}
			});
		}
	});
});
</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>